<!DOCTYPE html>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title></title>
                <script type="text/javascript" src="../../inc/ctx.jsp"></script>
                <script type="text/javascript" src="../js/g.js"></script>
                <link href="../css/com.css" type="text/css" rel="stylesheet"/>
	</head>
<body style="width:950px;height:300px;overflow:auto;">                  
<style type="text/css">
div,ul,li,a,b{padding:0px;margin:0px; list-style:none;}
#cat_area{width:930px;overflow:auto;margin:3px;height:256px;padding:3px 0px 0px 3px;background:#EFEFEF;border:1px #E0E0E0 solid;}
#cat_area ul{width:200px;overflow:auto;height:250px;float:left;border:1px #E0E0E0 inset;background:#fff;}
.f{float:left;height:255px;width:auto;margin-left:2px;}
#cat_area ul li{height:17px;padding:2px 0px 0px 3px;}
#cat_area ul li a{color:#333;font-size:12px;padding-left:2px;font-family:Tahoma, Geneva, sans-serif; text-decoration:none;width:96%;float:left;}
#cat_area ul li b{float:right;width:12px;font-size:12px;}
#cat_area ul li a:hover{color:#F63;}
#cat_area ul li a.cc{background:#5487DA;color:#fff;}
#submitBtn{padding:5px 19px 5px 19px;}
</style>  
<div>         
<div id="cat_area"></div>
<p style="text-align:center;"><input type="button" value=" 确 定 " onclick="CatList.preSubmitNext();" id="submitBtn" class="button orange"/></p>
</div>

<script type="text/javascript">
var infotype = ut.get('channeltype');
if(va.isnull(infotype)){
    alert('Channel Type Is Null.');
}
var CatList={
	url:'../app/catalogs/list_factor.shtm',
	p:{},
	t1:'<ul id="d@rid">@li</ul><div id="c@rid" class="f"></div>',
	t2:'<li><a code="@rid" href="javascript:CatList.load(@cid,@rid,\'@ctp\',@ndn,\'@ti\');">@cid-@ti @next</a></li>',
	init:function(d){
		var a=[];
		var c0 = d.list||[];
		for(var i=0; i<c0.length; i++){
			a.push(CatList.t2
			.replace(/@ti/g,c0[i].cname)
			.replace(/@cid/g,c0[i].cid)
			.replace(/@ctp/,c0[i].ctp)
			.replace(/@rid/g,c0[i].rid)
			.replace(/@ndn/,c0[i].nodenum)
			.replace(/@next/,c0[i].nodenum>0?'→':'')
			);
		}
		var s = CatList.t1.replace(/@li/,a.join('')).replace(/@rid/g,'0');
		$('#cat_area').html(s);
		CatList.pick();
	},
	load:function(id,rid,cp,ndn,ti){
		$.get(CatList.url,{'rid':id,'infotype':infotype,'colfilter':'colfilter'},function(x){
		var a=[];
				var c=x.list||[];
				// 这里可以使用AJAX JSON动态导入分类数据改变 c  值
				CatList.p.cid=id;
				CatList.p.ctp=cp;
				CatList.p.nodenum=ndn;
				if(c.length<1){
				$('#c'+rid).html('');
				return;
				}
				//
		for(var i=0; i<c.length; i++){
			a.push(CatList.t2
			.replace(/@ti/g,c[i].cname)
			.replace(/@cid/g,c[i].cid)
			.replace(/@ctp/,c[i].ctp)
			.replace(/@rid/,c[i].rid)
			.replace(/@ndn/,c[i].nodenum)
			.replace(/@next/,c[i].nodenum>0?'→':''));
		}
		var s = CatList.t1.replace(/@li/,a.join('')).replace(/@rid/g, id.toString());
		$('#c'+rid).html(s);
		CatList.pick();
		});	
	},
	pick:function(){
		$('#cat_area ul li a').each(function(i){
			$(this).click(function(e){
				var rid = $(this).attr('code');
				 $('#d'+rid+' a').each(function(k){
					 $(this).removeClass('cc');
				 });
				 $(this).addClass('cc');
			});
		});
	},
	preSubmitNext:function(){
	var j=CatList.p;
	if(va.isnull(j.nodenum) || j.nodenum>0){
	alert('请选择终极类别进行信息发布.');
	}else{
	window.parent.window.reloadCatData(j.cid,j.ctp);
	}
	}
};

$.get(CatList.url,{'rid':0,'infotype':infotype,'colfilter':'colfilter'},CatList.init);
</script>
	</body>
</html>